home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 6 / CU Amiga Magazine's Super CD-ROM 06 (1996)(EMAP Images)(GB)(Track 1 of 4)[!][issue 1997-01].iso / cucd / prog / mui / muirexx2.2 / demos / muirexxbuild / comm.rexx < prev    next >
OS/2 REXX Batch file  |  1996-10-07  |  5KB  |  181 lines

  1. /* */
  2. options results
  3. parse arg comm
  4.  
  5. /* Attribute TAG ID definitions */
  6.  
  7. List_Active =                     0x8042391c /* V4  isg LONG              */
  8. ASLFR_DrawersOnly =               0x8008002f
  9. ASLFR_InitialDrawer =             0x80080009
  10.  
  11. TRUE = 1
  12. List_Insert_Bottom = -3
  13.  
  14. address BUILD
  15.  
  16. select
  17.     when comm = 'LEFT' then do
  18.         list ID DLST ATTRS List_Active
  19.         dpos = result
  20.         list ID DLST POS dpos
  21.         gobj = substr(result,2)
  22.         parse var gobj obj .
  23.         nspc = pos(obj,gobj)-1
  24.         if nspc > 0 then do
  25.             list ID DLST POS dpos STRING '='||insert(strip(gobj),'',nspc-1)
  26.         end
  27.     end
  28.     when comm = 'RIGHT' then do
  29.         list ID DLST ATTRS List_Active
  30.         dpos = result
  31.         list ID DLST POS dpos
  32.         gobj = substr(result,2)
  33.         parse var gobj obj .
  34.         nspc = pos(obj,gobj)-1
  35.         if nspc >= 0 then do
  36.             list ID DLST POS dpos STRING '='||insert(strip(gobj),'',nspc+1)
  37.         end
  38.     end
  39.     when comm = 'COPY' then do
  40.         list ID DLST ATTRS List_Active
  41.         dpos = result
  42.         i = 0
  43.         do forever
  44.             list ID DLST
  45.             if result = '' then break
  46.             i = i + 1
  47.             line.i = result
  48.         end
  49.         do n = 1 to i
  50.             list ID DLST INSERT POS dpos+n STRING line.n
  51.         end
  52.     end
  53.     when comm = 'CREATE' then do
  54.         string ID APRT
  55.         aport = upper(result)
  56.         if aport = '' then exit
  57.         if show('ports',aport) then do
  58.             address value aport
  59.             quit
  60.             address
  61.             do while show('ports',aport)
  62.             end
  63.         end
  64.         call writemacro 't:tmp'
  65.         address command 'run >nil: MUIRexx:MUIRexx PORT 'aport' t:tmp'
  66.         address command 'delete t:tmp.rexx QUIET'
  67.     end
  68.     when comm = 'CLOSE' then do
  69.         string ID APRT
  70.         aport =  upper(result)
  71.         if show('ports',aport) then do
  72.             address value aport
  73.             quit
  74.             address
  75.         end
  76.     end
  77.     when comm = 'NEW' then do
  78.         list ID DLST STRING
  79.         list ID VLST STRING
  80.         string ID APRT CONTENT ''
  81.     end
  82.     when comm = 'SAVE' then do
  83.         getvar directory
  84.         aslrequest ID BWIN TITLE '"Select Directory"' ATTRS ASLFR_DrawersOnly TRUE ASLFR_InitialDrawer result
  85.         dir = result
  86.         if (~exists(dir)) then exit
  87.         setvar directory dir
  88.         if lastpos('/',dir) ~= length(dir) then do
  89.             if lastpos(':',dir) ~= length(dir) then dir = dir'/'
  90.         end
  91.         string ID APRT
  92.         aport = result
  93.         name = dir||aport
  94.         call writemacro name
  95.         address command 'copy build:build.info 'name'.info QUIET'
  96.     end
  97.     when comm = 'SAVEAS' then do
  98.         getvar directory
  99.         aslrequest ID BWIN TITLE '"Select File"' ATTRS ASLFR_InitialDrawer result
  100.         if rc = 0 then do
  101.             file = result
  102.             if lastpos('/',file) ~= 0 then dir = substr(file,1,lastpos('/',file)-1)
  103.             else dir = substr(file,1,lastpos(':',file))
  104.             setvar directory dir
  105.             call writemacro file
  106.         end
  107.     end
  108.     when comm = 'READ' then do
  109.         getvar directory
  110.         aslrequest ID BWIN TITLE '"Select File"' ATTRS ASLFR_InitialDrawer result
  111.         name = result
  112.         if (~exists(name)) then exit
  113.         if lastpos('/',name) ~= 0 then dir = substr(name,1,lastpos('/',name)-1)
  114.         else dir = substr(name,1,lastpos(':',name))
  115.         setvar directory dir
  116.         list ID DLST STRING
  117.         list ID VLST STRING
  118.         call open('file',name,'R')
  119.  
  120.         aport = ''
  121.         do while ~eof('file')
  122.             line = readln('file')
  123.             if strip(line) = '' then iterate
  124.             if index(strip(line),'/*') = 1 then iterate
  125.             if index(line,'=') > 0 then do
  126.                 parse var line vname op value .
  127.                 if strip(op) = '=' then do
  128.                     list ID VLST INSERT POS List_Insert_Bottom STRING strip(vname)' = 'strip(value)
  129.                     iterate
  130.                 end
  131.             end
  132.             if aport = '' then do
  133.                 if index(line,'address') = 1 then do
  134.                     parse var line 'address 'pname comm
  135.                     if comm = '' then do
  136.                         aport = pname
  137.                         string ID APRT CONTENT aport
  138.                         iterate
  139.                     end
  140.                 end
  141.             end
  142.             list ID DLST INSERT POS List_Insert_Bottom STRING '='||line
  143.         end
  144.         call close('file')
  145.     end
  146.     otherwise nop
  147. end
  148.  
  149. exit
  150.  
  151. writemacro: procedure
  152. parse arg name
  153.  
  154. string ID APRT
  155. aport = result
  156. if index(name,'.rexx') = 0 then name = name'.rexx'
  157. call open('file',name,'W')
  158. call writeln('file','/* Application created by MUIBuild */')
  159. call writeln('file','')
  160. call writeln('file','address 'aport)
  161. call writeln('file','')
  162. i = 0
  163. do forever
  164.     list ID VLST POS i
  165.     line = result
  166.     if line = '' then break
  167.     call writeln('file',line)
  168.     i = i + 1
  169. end
  170. call writeln('file','')
  171. i = 0
  172. do forever
  173.     list ID DLST POS i
  174.     line = result
  175.     if line = '' then break
  176.     call writeln('file',substr(line,2))
  177.     i = i + 1
  178. end
  179. call close('file')
  180. return
  181.